package com.car.android.sdk;

import android.app.Activity;
import android.content.Context;
import android.util.Log;

import com.car.android.sdk.bridge.CarCocosBridge;
import com.car.android.sdk.kwai.CarKwaiReward;


public class CarBusiness {

    public static Context context;
    private static final String GAME_MAIN_CLS = "org.cocos2dx.javascript.BusActivity";
//    private static final String GAME_MAIN_CLS = "com.test.app.MainActivity";

    public static void init(Context ctx) {
        try {
            context = ctx.getApplicationContext();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void onActivityCreate(Activity activity) {
        try {
            if (activity.getClass().getName().equals(GAME_MAIN_CLS)) {
                CarCocosBridge.getInstance().setMainGameActivity(activity);
//                Log.e("CCMatchW", "onActivityCreate");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void onGameActivityResume(Activity activity){
        try{
            if (activity.getClass().getName().equals(GAME_MAIN_CLS)) {
                CarCocosBridge.getInstance().onMainGameActivityResume();
//                Log.e("CCMatchW", "onGameActivityResume");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    public static void onGameActivityPaused(Activity activity) {
        try{
            if (activity.getClass().getName().equals(GAME_MAIN_CLS)) {
                CarCocosBridge.getInstance().onMainGameActivityPause();
//                Log.e("CCMatchW", "onMainGameActivityPause");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    public static void onActivityDestroyed(Activity activity) {
        try{
            if (activity.getClass().getName().equals(GAME_MAIN_CLS)) {
                CarKwaiReward.getInstance().onDestroy();
//                Log.e("CCMatchW", "onActivityDestroyed");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
